<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>修改员工信息</title>
    <link href="../../css/style.css" rel="stylesheet" type="text/css">

    <script src="../../layui/layui.js"></script>
    <link href="../../layui/css/layui.css">
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<center>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
            <td height="25" align="center" valign="bottom" class="td06">
                <table width="98%" border="0" cellspacing="3" cellpadding="0">
                    <tr>
                        <td width="15"><img src="../../images/index_32.gif" width="9" height="9"></td>
                        <td valign="bottom" class="title">修改员工信息</td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
    <form name="form1" method="post" action="" id="suts_value">
        <table width="95%" border="0" cellpadding="0" cellspacing="0">

            <input type="hidden" value="" id="sta" name="staid">

            <tr>
                <td width="90" align="center" class="td_form01">员工姓名</td>
                <td colspan="3" class="td_form02"><input name="staname" type="text" class="input" id="names"></td>
            </tr>
            <tr>
                <td width="90" align="center" class="td_form01">员工性别</td>
                <td colspan="3" class="td_form02"><select id="sexs" name="stasex">
                    <option>男</option>
                    <option>女</option>
                </select></td>
            </tr>

            <tr>
                <td width="90" align="center" class="td_form01">员工年龄</td>
                <td colspan="3" class="td_form02"><input name="staage" type="text" class="input" id="age"></td>
            </tr>

            <tr>
                <td width="90" align="center" class="td_form01">员工住址</td>
                <td colspan="3" class="td_form02"><input name="staaddress" type="text" class="input" id="address"></td>
            </tr>
            <tr>
                <td width="90" align="center" class="td_form01">员工电话</td>
                <td colspan="3" class="td_form02"><input name="statel" type="text" class="input" id="tel"></td>
            </tr>
            <tr>
                <td width="90" align="center" class="td_form01">所属科室</td>
                <td colspan="3" class="td_form02"><select name="deptype">
                    <option>外科</option>
                    <option>内科</option>
                    <option>耳鼻喉科</option>
                </select></td>
            </tr>


            <tr>
                <td width="90" align="center" class="td_form01">员工原职位</td>
                <td colspan="3" class="td_form02"><input type="text" class="input" id="postitle"></td>
                </td>
            </tr>


            <tr>
                <td width="90" align="center" class="td_form01">员工新职位</td>
                <td colspan="3" class="td_form02">
                    <input type="checkbox" name="postitleList" value="1">医师
                    <input type="checkbox" name="postitleList" value="2">主任
                    <input type="checkbox" name="postitleList" value="3">药师
                </td>
            </tr>
        </table>
        <br>
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td align="center"><input name="Submit" type="button" class="buttonface" value="修改" onclick="sut()">
                    <input name="Submit" type="button" class="buttonface" onClick="window.close()" value="  关闭  "></td>
            </tr>
        </table>
    </form>
</center>
</body>
</html>
<script src="../../bootstrap-3.3.7-dist/js/jquery-3.4.1.min.js"></script>
<script>
    //获取URL的值
    //selected disabled hidden 隐藏属性

    $(function () {
        var url = location.search; //获取url中"?"符后的字串
        if (url.indexOf("?") != -1) {    //判断是否有参数
            var str = url.substr(1); //从第一个字符开始 因为第0个是?号 获取所有除问号的所有符串
            strs = str.split("&");   //用等号进行分隔 （因为知道只有一个参数 所以直接用等号进分隔 如果有多个参数 要用&号分隔 再用等号进行分隔）
            // $("#sta").val(decodeURI(strs[0]))
            $("#sta").val(decodeURI(strs[1]))
            $("#names").val(decodeURI(strs[2]))
            $("select:first > option:first").html(decodeURI(strs[3]))
            $("#age").val(decodeURI(strs[4]))
            $("#address").val(decodeURI(strs[5]))
            $("#tel").val(decodeURI(strs[6]))
            $("select:eq(1)> option:first").html(decodeURI(strs[7]))
            $("#postitle").val(decodeURI(strs[8]))
        }
    })


    function sut() {

        $.ajax({
            url: "/feign/staffinfo/update",
            type: "put",
            data: $("#suts_value").serialize(),
            headers: {
                Accept: "application/json; charset=utf-8",
                Authorization: location.href.split("=")[1].split("&")[0]
            },
            // dataType: "json",
            success: function (data) {

                   if(data.code==200){
                    opener.location.href = "rolelist.htm?token="+location.href.split("=")[1].split("&")[0];
                    window.close();
                   }
            }
        })
    }
</script>
